/**
 * 账户布局页面逻辑
 *
 * @版权所有 rem.studio
 */
import React, { Component, Fragment } from 'react';
import { connect } from 'dva';
import Link from 'umi/link';
import { Icon } from 'antd';
import GlobalFooter from '@/components/GlobalFooter';
import DocumentTitle from 'react-document-title';
import SelectLang from '@/components/SelectLang';
import styles from './UserLayout.less';
import getPageTitle from '@/utils/getPageTitle';

class UserLayout extends Component {
  componentDidMount() {
    const {
      dispatch,
      route: { routes, authority },
    } = this.props;
    dispatch({
      type: 'menu/getMenuData',
      payload: { routes, authority },
    });
  }

  state = {
    collapse: 'block',
    right: '130px',
  };
  togglerContent = () => {
    const { collapse, right } = this.state;
    if (collapse === 'none') {
      this.setState({ collapse: 'block' });
    } else {
      this.setState({ collapse: 'none' });
    }
    if (right === '0px') {
      this.setState({ right: '130px' });
    } else {
      this.setState({ right: '0px' });
    }
  };

  render() {
    const {
      children,
      location: { pathname },
      breadcrumbNameMap,
    } = this.props;
    const { collapse, right } = this.state;

    const copyright = (
      <Fragment>
        <span style={{ color: '#ffffff' }}>
          农村癌症人群筛查系统 <Icon type="copyright" /> 2022
        </span>
      </Fragment>
    );

    return (
      <DocumentTitle title={getPageTitle(pathname, breadcrumbNameMap)}>
        <div className={styles.container}>
          <div className={styles.content}>
            {/*<div className={styles.top}>*/}
            {/*  <div className={styles.header}>*/}
            {/*    <Link to="/">*/}
            {/*      <span className={styles.title}>安徽鼎客固废监管平台</span>*/}
            {/*    </Link>*/}
            {/*  </div>*/}
            {/*</div>*/}
            {children}
          </div>
          <GlobalFooter copyright={copyright} />
        </div>
      </DocumentTitle>
    );
  }
}

export default connect(({ menu: menuModel }) => ({
  menuData: menuModel.menuData,
  breadcrumbNameMap: menuModel.breadcrumbNameMap,
}))(UserLayout);
